// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';
// 申明请求对象
const userRequest = {
  // 请求的基本url
  BASE_URL: confing.CAL_URL + "/user",

  //根据用户id查询数据
  getByUserId(userId,callback){
    let url = this.BASE_URL + "/getByUserId?userId=" + userId;
    // 发送请求
    request.get(url,callback);
  },
  // 根据部门id查询用户数据
  selectByDepartmentId(departmentId,callbcak){
    let url = this.BASE_URL + "/selectByDepartmentId?departmentId=" + departmentId;
    // 发送请求
    request.get(url, callbcak);
  },

  // 请求的API
  list(page = 1, limit = 10, user, callbcak) {
    // url
    let url = this.BASE_URL + "/list?page=" + page +
      "&limit=" + limit;
    if (user) {
      if (user.userName) {
        url += "&userName=" + user.userName;
      }
      if (user.tel) {
        url += "&tel=" + user.tel;
      }
    }
    // 发送请求
    request.get(url, callbcak);
  }
}
// 将dictRequest暴漏出去
export default userRequest;